package string;

/**
 * String支持正则表达式方法三:
 * String replaceAll(String regex,String replacement)
 * 将满足正则表达式的部分全部替换为
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String line = "abc123def456ghi";
        //String newline =line.replaceAll("[0-9]+","NUMBER");
        //System.out.println(newline);

        String newline =line.replaceAll("[a-z]+","NUMBER");
        System.out.println(newline);

        //和谐用语
        String regex ="(wqnmlgb|dsb|nc|cnm|mdzz|nmsl|djb)";
        String message = "wqnmlgb!你个dsb!你怎么这么的nc!你个djb!";
        message=message.replaceAll(regex,"***");
        System.out.println(message);














    }
}
